// 引入api
import {} from "../../request/api"
// 初始值
const initState = {
    // 初始化data
    data: {},
}

// actionsTypes
const types = {
    // 修改数据 type
    CHANGE_DATA: "REGISTER_CHANGE_DATA",
}

// reducer 修改数据
const reducer = (state = initState, action) => {
    switch (action.type) {
        case types.CHANGE_DATA:
            return {
                ...state,
            }
        default:
            return state;
    }

}

// actionCreators组件派发的动作
export const actions={
    // 修改user的action
    changeData:(key,value)=>({type:types.CHANGE_DATA,key,value}),

    //逻辑操作

    
    // 注册请求(异步操作)
    reqLogin:(history)=>(dispatch,getState)=>{
        let { data } = getState().register;
        reqLogin(data).then(res => {
            if (res.data.code === 200) {
                //跳转页面
                history.push("/index/store")
            }
        })
    }
}

//selectors导出数据 
export const getData=state=>state.register.data;
  
export default reducer